#ifndef _UART_H_
#define _UART_H_

/* Includes ------------------------------------------------------------------*/
#include "fm33lg0xx_fl.h"
#include "main.h"

/* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */
#ifdef _UART_C_
#include "dataflash.h"
#include "relay.h"
#endif
/* USER CODE END Includes */

/* Exported constants --------------------------------------------------------*/
/* USER CODE BEGIN EC */

/* USER CODE END EC */

/* Exported macro ------------------------------------------------------------*/
/* USER CODE BEGIN EM */
#define USART_RX_BUFFER_SIZE                                      (32)

#define GET_USART_RX_START_FLG()                                  (gucUsartFlags & BIT0)
#define SET_USART_RX_START_FLG()                                  (gucUsartFlags |= BIT0)
#define CLR_USART_RX_START_FLG()                                  (gucUsartFlags &= ~BIT0)

#define GET_USART_RX_FINISHED_FLG()                               (gucUsartFlags & BIT1)
#define SET_USART_RX_FINISHED_FLG()                               (gucUsartFlags |= BIT1)
#define CLR_USART_RX_FINISHED_FLG()                               (gucUsartFlags &= ~BIT1)

#define GET_R_Flashing()                                          (gucUsartFlags & BIT2)
#define SET_R_Flashing()                                          (gucUsartFlags |= BIT2)
#define CLR_R_Flashing()                                          (gucUsartFlags &= ~BIT2)

#define GET_G_Flashing()                                          (gucUsartFlags & BIT3)
#define SET_G_Flashing()                                          (gucUsartFlags |= BIT3)
#define CLR_G_Flashing()                                          (gucUsartFlags &= ~BIT3)

#define GET_B_Flashing()                                          (gucUsartFlags & BIT4)
#define SET_B_Flashing()                                          (gucUsartFlags |= BIT4)
#define CLR_B_Flashing()                                          (gucUsartFlags &= ~BIT4)
/* USER CODE END EM */

/* Exported types ------------------------------------------------------------*/
/* USER CODE BEGIN ET */
typedef struct{
	uint8_t ucAryBuffer[USART_RX_BUFFER_SIZE];
	uint8_t ucSize;
}STUartData;
/* USER CODE END ET */

/* Exported functions prototypes ---------------------------------------------*/
/* USER CODE BEGIN EFP */
void vUART0Init(void);
//void vUART4Init(void);
//void vRX485Send(uint8_t *pdata, uint8_t ucSize);
//void vRS485BufferClr(void);
void vUART0MsgHandler(void);

extern STUartData stUart0Rx;
extern uint8_t gucUsartFlags;
extern uint8_t gucUsartRxTimerCnt;
/* USER CODE END EFP */

/* Private defines -----------------------------------------------------------*/

/* USER CODE BEGIN Private defines */

/* USER CODE END Private defines */
#endif // _UART_H_
